import React, { Fragment } from "react";
import Modal from "./Modal";
//使用Modal组件的时候 可以传递处理函数 处理点击确定的逻辑 和处理 点击取消的逻辑
class App extends React.Component {
  state = {
    visible: false,
  };
  handleOk = () => {
    // alert("充值成功");
    //关闭模态框
    this.setState({
      visible: false,
    });
  };
  handleCancel = () => {
    // alert("充值失败");
    //关闭模态框
    this.setState({
      visible: false,
    });
  };
  render() {
    return (
      <Fragment>
        <button
          onClick={() => {
            this.setState({
              visible: true,
            });
          }}
        >
          点击显示模态框
        </button>
        <Modal
          visible={this.state.visible}
          title="充值提示"
          onOk={this.handleOk}
          onCancel={this.handleCancel}
        ></Modal>
      </Fragment>
    );
  }
}
export default App;
